<template>
	<view>
		<view class="homeStyle">
			<view class="topbgbox">
				<dateTimeVue></dateTimeVue>
			</view>
			<view class="topnavbox">
				<view class="cardItem" v-for="(item,index) in cardData" :key="index">
					<view @click="goindexNav(index)" class="navbos">
						<image class="logo" :src="item.img"></image>
						<view class="navtitle">{{item.title}}</view>
					</view>
				</view>
			</view>

			<!-- 	<navigator url="/pages/performingLoan/Map" hover-class="navigator-hover">
				<button type="default">测试</button>
			</navigator> -->

			<view class="gonggaobox">
				<u-notice-bar :text="text1" style="border-radius: 14rpx;"></u-notice-bar>
			</view>
			<!-- <marquee class="gonggaobox" :announcements="renwuList" :interval="3000" :duration="600"></marquee> -->
			<view class="" style="display: flex;    align-items: center; color: gary; font-size: 27rpx;">
				<image class="remindLogo" src="/static/remind.png"></image>
				<text>消息提醒</text>
				<!-- <u--image   src=""></u--image> -->
			</view>
			<!-- <div style="flex: 1; background-color: pink;">
				213
			</div> -->
			<message class="messagebox" :data="marqueeData" :speed="30" :itemHeight="60" style="flex: 1;" />
			<!-- 备案号 -->
			<filing></filing>
		</view>

		<tabbar :value='0'></tabbar>
	</view>
</template>

<script>
	import tabbar from "@/components/tabbar.vue"
	import marquee from "@/components/marquee.vue"
	import message from "@/components/message.vue"
	import filing from "@/components/filing.vue"
	import dateTimeVue from "@/components/dateTime.vue"
	import IsLogin from "@/utils/IsLogin"
	import request from "../../utils/request"
	import apiurl from "../../utils/api"
	import {
		getCurrentDateCN
	} from "../../utils/date"
	export default {
		components: {
			tabbar,
			marquee,
			message,
			filing,
			dateTimeVue
		},
		data() {
			return {
				currentDateCN: '', //时间日期
				text1: "欢迎使用本系统，祝您使用愉快,系统将于今晚23:00进行维护，请提前做好准备,最新活动：邀请好友注册可获得额外积分,重要通知：请及时更新您的个人信息",
				cardData: [{
					title: '开门红',
					img: "/static/index/kmh.png",
				}, {
					title: '网格管理',
					img: "/static/index/wanggeguanli.png",
				}, {
					title: '任务管理',
					img: "/static/index/renwuguanli.png",
				}, {
					title: '数据管理',
					img: "/static/index/shujuguanli.png",
				}, {
					title: '活动管理',
					img: "/static/index/huodongguanli.png",
				}, {
					title: '学习园地',
					img: "/static/index/study.png",
				}],
				renwuList: [
					"最新公告1：系统将于今晚进行维护升级",
					"活动通知2：本周六将举办线下技术交流会",
					"重要提醒3：请及时更新个人信息",
					"行业动态4：Vue 3.3版本正式发布",
					"温馨提示5：近期注意防范网络诈骗"
				],
				marqueeData: [{
						content: "第一条消息内容",
						ctime: "2023-10-01 08:30:00"
					},
					{
						content: "第二条消息内容",
						ctime: "2023-10-01 08:30:00"
					},
					{
						content: "第三条消息内容",
						ctime: "2023-10-01 08:30:00"
					},
					{
						content: "第4条消息内容",
						ctime: "2023-10-01 08:30:00"
					},
					{
						content: "第5条消息内容",
						ctime: "2023-10-01 08:30:00"
					},
				],


			}
		},
		onLoad() {
			//用户没登录 就去授权登录
			IsLogin() //封装公共的方法

		},
		created() {
			this.notificationXlb()
			this.currentDateCN = getCurrentDateCN();
		},
		methods: {
			notificationXlb() {
				request(apiurl.notificationXlb, "GET")
					.then(res => {
						console.log(res);
						this.text1 = res.data[0].content;
					})
					.catch(err => {
						console.log(err);
					})
			},
			clickCard(item) {
				uni.showToast({
					title: item.title, // 提示内容（必填）
					icon: "none", // 图标：success/error/loading/none（默认success）
					duration: 1000, // 显示时长（ms，默认1500）
					position: "top" // 位置：top/middle/bottom（默认middle）
				});
			},
			goindexNav(i) {
				switch (i) {
					case 0:
						uni.navigateTo({
							url: "/homeNav/opendoored/opendoored"
						})
						break;
					case 1:
						uni.navigateTo({
							url: "/pages/gridManagement/index"
						})
						break;
					case 2:
						uni.navigateTo({
							url: "/homeNav/rwgl/rwgl"
						})
						break;
					case 3:
						uni.navigateTo({
							url: "/homeNav/statistics/index"
						})
						break;
					case 4:
						uni.navigateTo({
							url: "/pages/active/active"
						})
						break;
					case 5:
						uni.navigateTo({
							url: "/homeNav/xxtd/xxtd"
						})
						break;
					default:
						break;
				}
			}

		}
	}
</script>

<style lang="less">
	.homeStyle {
		height: calc(100vh - 90rpx);
		width: 100%;
		display: flex;
		flex-direction: column;

		.topbgbox {
			width: 100%;
			height: 260rpx;
			background-color: #063e7d;

			.hytxt {
				color: #fff;
				margin-left: 30rpx;
				padding-top: 25rpx;
			}

			.showtime {
				color: #fff;
				margin-left: 30rpx;
				margin-top: 10rpx;
			}
		}

		.topnavbox {
			width: 94%;
			margin-left: 3%;
			background-color: #fff;
			box-shadow: rgba(17, 17, 26, 0.1) 0px 0px 18rpx;
			border-radius: 20rpx;
			display: flex;
			flex-flow: row wrap;
			align-items: center;
			padding: 20rpx 0;
			margin-top: -80rpx;

			.cardItem {
				width: 33%;

				.navbos {
					width: 100%;
					margin-top: 15rpx;

					.logo {
						width: 110rpx;
						height: 110rpx;
						margin: 0 auto;
						display: block;
					}

					.navtitle {
						text-align: center;
					}
				}

			}
		}

		.gonggaobox {
			margin-top: 10rpx;
			width: 94%;
			margin-left: 3%;
		}

		.messagebox {
			height: 500rpx;
			width: 94%;
			margin-left: 3%;
		}
	}

	.remindLogo {
		width: 50rpx;
		height: 50rpx;
		// margin: 0 auto;
		margin: 10rpx 10rpx 10rpx 30rpx;
		display: block;
	}

	.headerSyle {
		background-color: #063e7d;
		height: 15vh;
	}

	.viewStyle {
		// height: 85vh;
		// position: absolute;
		// position: relative;
		// padding: 0 30rpx;
		// top: -220rpx;
		// color: black;

		// 分类卡片样式
		// .cardBox {
		// 	// height: 390rpx;
		// 	height: 24vh;
		// 	background-color: white;
		// 	border-radius: 30rpx;
		// 	display: flex;
		// 	flex-wrap: wrap;
		// 	justify-content: space-between;


		// height: 100vh;
		// 横向消息轮播
		.carouselBox {
			height: 5vh;
			margin: 30rpx 0;
		}

		// 消息提醒样式
		.messageBox {
			.messageView {
				// height: 600rpx;
				height: 49vh;
				margin-top: 30rpx;
				overflow-y: scroll;

				.messageItem {
					padding: 10rpx 30rpx;
					box-sizing: border-box;
					height: 80px;
					background-color: white;
					border-radius: 30rpx;
					margin-bottom: 30rpx;

					.messageHeaderItem {
						display: flex;
						font-size: 24rpx;
						justify-content: space-between;

					}

					.messageViewItem {
						width: 100%;
						// padding: 20rpx 30rpx;
					}
				}
			}
		}
	}



	.marquee-container {

		border-radius: 15rpx;
		width: 100%;
		height: 40px;
		background-color: #e8e800;
	}

	.marquee-swiper {
		height: 100%;
	}

	.marquee-item {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		box-sizing: border-box;
	}

	.message-text {
		padding: 0 10rpx;
		font-size: 28rpx;
		color: #333;
		/* 单行文本溢出显示省略号 */
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>